import datetime
from django.db import models


class BaseModel(models.Model):
    created_at = models.DateTimeField(
        auto_now_add=True,
        editable=False,
        db_index=True,
    )
    modified_at = models.DateTimeField(
        auto_now=True,
        editable=False,
        db_index=True,
    )
    deleted_at = models.DateTimeField(
        default=datetime.datetime.min,
        null=True,
        blank=True,
        db_index=True,
    )

    class Meta:
        ordering = ['-created_at']
        get_latest_by = "modified_at"
        abstract = True
